<?php
/* @var array $apartamente {etaj => array {id, proprietar,  numar} } */
/* @var Scara $Scara */
?>

<div>

    <table class="apartamente-table" id="apartamente-table-<?php echo $Scara->getId() ?>">
        <thead>
            <tr>
                <th>Etaj</th>
                <th>Nr.</th>
                <th>Nume proprietar</th>
            </tr>
        </thead>

        <tbody>
            <?php foreach ($apartamente as $etaj => $rows): ?>
                <tr class="apartament-<?php echo $rows[0]['ID'] ?>">
                    <td class="etaj" rowspan="<?php echo count($rows) ?>"><?php echo $etaj ?></td>
                    <td class="number"><?php echo $rows[0]['NUMBER'] ?></td>
                    <td class="proprietar"><?php echo $rows[0]['PROPRIETAR'] ?></td>
                </tr>
                <?php for ($i = 1; $i < count($rows); $i++): ?>
                    <tr class="apartament-<?php echo $rows[$i]['ID'] ?>">
                        <td class="number"><?php echo $rows[$i]['NUMBER'] ?></td>
                        <td class="proprietar"><?php echo $rows[$i]['PROPRIETAR'] ?></td>
                    </tr>
                <?php endfor; ?>
            <?php endforeach; ?>
        </tbody>
    </table>

</div>

<script type="text/javascript">
    ApartamenteTable.showDetails('details-<?php echo $Scara->getId() ?>', 'apartamente-table-<?php echo $Scara->getId() ?>');
</script>
